package com.game.ammo {
	import com.game.data.Data;
	import com.game.units.Enemy;
	import com.game.utils.TowerType;
	import flash.geom.Matrix;
	import flash.geom.Point;
	public class Rocket extends Ammo {
		private var position:Number = 0;
		private var currentPosition:Point;
		private var rocketSize:Number = 2;
		public function Rocket(bulX:Number, bulY:Number, ang:Number, destination:Number, type:TowerType, upgrades:int, suggestiveDistance:int) {
			super(bulX, bulY, ang, destination, type, upgrades, suggestiveDistance);
		}
		override public function isHit(p3:Enemy):Boolean {
			if (pointToPointDistance(p3, currentPosition) < p3.size / 2 + rocketSize) {
				return true;
			}
			return false;
		}
		override protected function hitAction():void {
			readyForRemoval = true;
			move();
		}
		override protected function initialSet():void {
			ammoSpeed = 8;
			this._damage = (upgrades + 1) * 8;
			currentPosition = new Point(0, 0);
			//
			this._rect.width = 50;
			this._rect.height = 50;
			var ang:Number = (_angle * 180 / Math.PI) + 180;
			ang = ang < 0 ? 360 + ang : ang;
			this._rect.x = Math.round(ang / 15) * 50;
		}
		override public function move():void {
			position += this.ammoSpeed;
			currentPosition.x = -position * Math.cos(this._angle) + this.x;
			currentPosition.y = -position * Math.sin(this._angle) + this.y;
			this._point.x = currentPosition.x - 25;
			this._point.y = currentPosition.y - 25;
			if (position > destination) {
				readyForRemoval = true;
			}
		}
	}
}